-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Fix Bash commands not recognizing global options #20900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds handling for global options (e.g. --help, --debug, --quiet, --verbose) in Bash command scripts so they recognize and properly process help and other flags rather than ignoring or misinterpreting them.
- Early global help detection moved earlier in brew.sh and guarded command dispatch logic with HOMEBREW_HELP.
- Added filtering of global flags in several Bash command handlers (which-formula.sh, --repository.sh) and a wrapper alias function in --version.sh.
- Adjusted shellenv.sh argument parsing to use a case statement for first argument classification.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/utils/ruby.sh | Prevents early return for vendor-install when help is requested. |
| Library/Homebrew/cmd/which-formula.sh | Skips global verbosity/debug flags during argument parsing. |
| Library/Homebrew/cmd/shellenv.sh | Rewrites first-argument handling via case to recognize global flags. |
| Library/Homebrew/cmd/--version.sh | Adds alias function for command name with leading dashes. |
| Library/Homebrew/cmd/--repository.sh | Filters out global flags before processing tap arguments. |
| Library/Homebrew/brew.sh | Moves global help detection earlier and gates command groups; alters version dispatch condition. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
63f7ac1 to
c0e00aa
Compare
Some Bash commands don't recognize global options like --help, --debug, etc. For --help, we fix this in brew.sh by redirecting to the Ruby code path when --help is detected. For the remaining global options, we add handling for them in the respective shell commands.
c0e00aa to
bd0ad8d
Compare
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR but I'm not sure this is an improvement, sorry 😭. --help will be dramatically slower than these various Bash commands and we're having to add net 25 lines for something no users seem to have complained about along with a bunch of nesting/checks scattered around where it's not obvious when/why/how they will be added/removed in future. I'm open to other approaches, though.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?Some Bash commands don't recognize global options like
--help,--debug, etc. For--help, we fix this inbrew.shby redirecting to the Ruby code path when--helpis detected. For the remaining global options, we add handling for them in the respective shell commands.